<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <ui:composition template="../TemplateAdmin.xhtml">
        <ui:define name="title">
            <h:outputText value="User Management"></h:outputText>
        </ui:define>       
        <ui:define name="body">      
            <h:form id="form">
                <p:growl id="messages" showDetail="true"/> 
                <p:dataTable id="dataTable" var="item" value="#{userController.items}" resizableColumns="true"
                             paginator="true" rows="10" paginatorPosition="bottom"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15" style="width: 100%" widgetVar="userTable"
                             editable="true">
                    <f:facet name="header">
                        <h:outputText value="List of User"/>
                        <p:outputPanel style="float: right">
                            <h:outputText value="Search by all fileds"/>
                            <h:inputText id="globalFilter" onkeyup="userTable.filter"/>
                        </p:outputPanel>
                    </f:facet>

                    <p:ajax event="rowEdit" listener="#{userController.onEdit}" update=":form:messages"/>
                    <p:ajax event="rowEditCancel" listener="#{userController.onEditCancel}" update=":form:messages"/>

                    <p:column headerText="ID" sortBy="#{item.usID}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usID}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usID}"/>
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Account" sortBy="#{item.usName}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usName}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usName}" />
                                 
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>                
                    <p:column headerText="UserName" sortBy="#{item.usUserName}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usUserName}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usUserName}" />                                   
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>

                    <p:column headerText="Email" sortBy="#{item.usEmail}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usEmail}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usEmail}" />
                                   
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Phone" sortBy="#{item.usPhone}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usPhone}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usPhone}"/>
                                   
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>
                    <p:column headerText="Adress" sortBy="#{item.usAdress}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usAdress}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usAdress}" />
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>               
                    <p:column headerText="Company" sortBy="#{item.usCompany}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usCompany}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:outputText value="#{item.usCompany}" />
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column>          
                    <p:column headerText="Status" sortBy="#{item.usStatus}">
                        <p:cellEditor>
                            <f:facet name="output">
                                <h:outputText value="#{item.usStatus}"/>
                            </f:facet>
                            <f:facet name="input">
                                <h:selectBooleanCheckbox value="#{item.usStatus}" />
                            </f:facet>
                        </p:cellEditor>                    
                    </p:column> 
                    <p:column headerText="Action">
                        <h:commandButton action="#{userController.resetPassword(item)}" value="Reset Password"/>
                    </p:column>
                    <p:column>
                        <p:rowEditor/>
                    </p:column>
                </p:dataTable>               
            </h:form>
        </ui:define>
    </ui:composition>
</html>

